const Controller = require('egg').Controller;
const {ObjectId}= require("mongodb");

class SelectController extends Controller {
    async index() {
        const {
            ctx
        } = this;
        var db = this.app.mongodb;
        console.log(ctx.query);
        var {id} = ctx.query;
        var arr = await db.collection("expenditure").updateMany({checked:true},{$set:{checked:false}})
        var res = await db.collection("expenditure").updateOne({_id:ObjectId(id)},{$set:{checked:true}})
        console.log(arr);
        console.log(res);
        ctx.body = res
    }
}

module.exports = SelectController;